Computing a symbolic bound for a procedure

ABSTRACT

A system that facilitates computing a symbolic bound with respect to a procedure that is executable by a processor on a computing device is described herein. The system includes a transition system generator component that receives the procedure and computes a disjunctive transition system for a control location in the procedure. A compute bound component computes a bound for the transition system, wherein the bound is expressed in terms of inputs to the transition system. The system further includes a translator component that translates the bound computed by the compute bound component such that the bound is expressed in terms of inputs to the procedure.

BACKGROUND

Due to advances in technologies, including advances pertaining to memory, processing capabilities, storage capacity, amongst others, computers have evolved from relatively high cost, low function machines to relatively low cost machines that can perform a variety of functions, including but not limited to complex mathematical computation, detailed graphics rendering, web browsing, etc. Furthermore, portable computing devices exist that allow many of the aforementioned functions to be executed on a portable device, such as mobile telephones and/or multimedia players. Additionally, computing devices have been deployed in a variety of contexts, such as in airplanes where real-time processing of sensor data is utilized to aid in maintaining control of an airplane, in automobile navigation systems to display a current location to an operator of the automobile, etc.

Programs executing on computing devices use physical resources of such computing devices, such as memory, processing time, power of a device, bandwidth on a network, etc. In many devices and/or contexts, the physical resources of a computing device are limited and/or are desirably closely monitored. For example, in real-time systems, it is desirable to bound the worst-case execution time of a program. In a program that is to be executed on a low power device or in a low bandwidth environment, it is desirable to bound the amount of power and/or bandwidth utilized by the computing device when executing the program. Estimating such resource bounds can be undertaken by determining the number of times one or more control locations inside a program that consumes these resources are executed.

Program execution can also affect certain quantitative properties of data upon which the program operates. For instance, the amount of secret leaked by a program can depend upon the number of times that a certain operation that leaks data is executed (e.g., by either direct or indirect information flow). Additionally, an amount of perturbation in output data values resulting from a relatively small perturbation or uncertainty in input values can depend upon the number of times additive error propagation operators are applied. Estimating such quantitative properties can be undertaken by determining the number of times one or more control locations inside a program that perform certain operations are executed.

Conventional approaches for ascertaining the number of times that a control location executes in a program are relatively imprecise and conservative in nature. An example approach for computing symbolic bounds on the number of times a control location executes in a program is to estimate a bound on a closest enclosing loop using techniques for loop bound computation. Again, however, this approach tends to be conservative and imprecise.

SUMMARY

The following is a brief summary of subject matter that is described in greater detail herein. This summary is not intended to be limiting as to the scope of the claims.

Described herein are various technologies pertaining to computing symbolic bounds on physical resources utilized by a program executing on a computing device. For example, various cost metrics can be utilized in connection with computing the symbolic bounds, including but not limited to cost metrics pertaining to memory instructions, cost metrics pertaining to allocation instructions (memory space bounds), and/or cost metrics pertaining to network instructions (network traffic bounds). The aforementioned symbolic bounds can be used in connection with providing feedback pertaining to code development, performance analysis, establishing space bounds in embedded systems, amongst other applications. Also described herein are various technologies pertaining to bounding the amount of secret leaked by a program at a certain control location in a program as well as bounding the amount of perturbation in output values with respect to a certain control location in a program.

In particular, described herein are various technologies for computing a worst-case symbolic bound on the number of visits to a certain control location in a procedure (e.g., a computer program) for any execution of such procedure on a computing device. The worst case symbolic bound can be defined as follows: an integer-valued function

({right arrow over (n)}) is a worst-case symbolic bound for a control location π inside a procedure P with inputs {right arrow over (n)} if for any input state {right arrow over (n₀)} the number of times π is visited is at most

({right arrow over (n₀)}).

To determine a worst case symbolic bound for a given control location, a plurality of acts can be undertaken. For example, a disjunctive transition system T for the control location π can be computed, wherein the disjunctive transition system T describes how variables in the procedure at π are updated in an immediately subsequent visit to the control location π. A bound

may then be computed for the transition system T, and the bound on the number of visits to π can be set as 1+

. The bound

can be expressed in terms of inputs to the transition-system T, which may or may not be the inputs to the procedure. Thus, the bound

can be translated at π in terms of the inputs to the procedure. For example, such translation can be undertaken through employment of invariants (computed from an invariant generation tool) that relates procedure inputs with inputs to the transition system T. In another example, a backward symbolic engine can be used to express inputs to the transition system T in terms of the procedure inputs.

Other aspects will be appreciated upon reading and understanding the attached figures and description.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a functional block diagram of an example system that facilitates computing a reachability bound for a procedure.

FIG. 2 is an example depiction of a component that facilitates generating a transition system with respect to a control location in a procedure.

FIG. 3 is a graphical depiction of an example splitting of a control location into two locations.

FIG. 4 is a graphical depiction of a summarization of a nested loop.

FIG. 5 is a graphical depiction of an example composition.

FIG. 6 is a graphical depiction of an example merging operation.

FIG. 7 is an example depiction of a component that facilitates computing a bound based at least in part upon a transition system pertaining to a control location of a procedure.

FIG. 8 is flow diagram that illustrates an example methodology for computing a reachability bound with respect to a control location of a procedure.

FIG. 9 is a flow diagram that illustrates an example methodology for computing a bound using a particular bound computing rule.

FIG. 10 is an example computing system.

DETAILED DESCRIPTION

Various technologies pertaining to computing a reachability bound with respect to a certain control location in a program will now be described with reference to the drawings, where like reference numerals represent like elements throughout. In addition, several functional block diagrams of example systems are illustrated and described herein for purposes of explanation; however, it is to be understood that functionality that is described as being carried out by certain system components may be performed by multiple components. Similarly, for instance, a component may be configured to perform functionality that is described as being carried out by multiple components.

With reference to FIG. 1, an example system 100 that facilitates computing a reachability bound for a certain control location in a procedure is illustrated. Computing the reachability bound pertains to computing a worst-case symbolic bound

({right arrow over (n)}) on the number of visits to a certain control location π in a procedure P for any execution of P. The worst-case symbolic bound

({right arrow over (n)}) can be defined as follows: an integer-valued function

({right arrow over (n)}) is a worst-case symbolic bound for a control location π inside a procedure P with inputs {right arrow over (n)} if for any input state {right arrow over (n₀)} the number of times π is visited is at most

({right arrow over (n₀)}).

It is to be understood that there may be multiple worst-case symbolic bounds for a certain control location, and it is desirable that the system 100 computes a bound that is precise in the sense that there exists a family φ({right arrow over (n)}) of worst case inputs that exhibit the worst-case bound (up to some constant factor). This notion can be defined as follows: a worst-case symbolic bound

({right arrow over (n)}) for a control location π inside a procedure P with inputs {right arrow over (n)} is precise (up to multiplicative constant factors) if there exists positive integers c₁, c₂, and c₃ and a formula φ({right arrow over (n)}) such that: 1) for any assignment {right arrow over (n₀)} to variables {right arrow over (n)} such that φ({right arrow over (n₀)}) holds, the number of times control location π is visited (when procedure P is executed in the input state {right arrow over (n₀)}) is at least

${\frac{B\left( \overset{\rightarrow}{n_{0}} \right)}{c_{1}} - c_{2}};$ and 2) for any integer k, there exists a satisfying assignment {right arrow over (n₁)} for φ({right arrow over (n)}) such that

({right arrow over (n₁)})>k. In other words, the formula ∃{right arrow over (n)}: (

({right arrow over (n)})≧k

φ({right arrow over (n)})) has a satisfying assignment.

The reachability bound computed by the system 100 can pertain to physical resources of a computing device, such as a bound on memory space utilized by a procedure (program) when executing on a computing device, a bound on time required to execute the procedure on a computing device, a bound on an amount of bandwidth consumed when executing the procedure on a computing device, an amount of power consumed by a computing device when executing the procedure, amongst other physical resources. The reachability bound computed by the system 100 may also be employed in connection with determining a bound on uncertainity propagation or secret leakage by some portion of a procedure. The system 100 can be utilized in connection with computing symbolic complexity bounds of procedures in terms of inputs (assuming unit cost for statements). Different cost metrics can be utilized when computing such symbolic complexity bounds, including count of memory instructions, count of memory allocation instructions (space bounds), count of network instructions (network traffic bounds), amongst others.

The system 100 includes a data repository 102 that comprises a procedure 104. The data repository 102 may be any suitable type of repository that can retain data, including but not limited to a hard drive, memory (such as ROM, RAM, EEPROM, amongst others), a flash drive, or other suitable repository. Additionally, the procedure 104 may be a plurality of computer-executable acts, such as code that includes a loop, a nested loop, code that includes a program or portion thereof, a portion of code utilized in an application program interface, or other suitable procedure.

A transition system generator component 106 can access the data repository 102 and retrieve/receive the procedure 104. For example, the transition system generator component 106 can access the data repository 102 upon receipt of a command from a user, upon a predefined event occurring on a computing device, or in response to some other event. The transition system generator component 106 can compute a disjunctive transition system T for the control location 7T, wherein the transition system T describes how the variables at 7T get updated in an immediately subsequent visit to the control location 7T. An example algorithm for generating the disjunctive transition system T that can be used by the transition system generator component 106 is described in greater detail below.

The system 100 may also optionally include a bound computation component 108 that is in communication with the transition system generator component 106. For example, the transition system generator component 106 and the bound computation component 108 can have access to a substantially similar portion of memory of a computing device (e.g., the transition system generator component 106 can cause the computed disjunctive transition system T to be stored in a portion of memory, and the bound computation component 108 can access such portion of memory). The bound computation component 108 can compute a bound

for the transition system T. For instance, the bound computation component 108, as will be described in greater detail below, can utilize pattern recognition techniques in connection with computing ranking functions of individual transitions pertaining to the transition system T, and such ranking functions can be utilized in connection with computing the bound. A bound on the number of visits to π may be given by 1+

.

The system 100 may also optionally include a translator component 110 that is in communication with the bound computation component 108. The bound

computed by the bound computation component 108 may be expressed in terms of inputs to the transition system T, which may or may not be inputs to the procedure P. The translator component 110 can translate the bound

at the control location π in terms of inputs to the procedure P. In an example, the translator component 110 may use invariants (computed from an invariant generation tool) that relate the procedure inputs with the inputs to the transition system T. In another example, the translator component 110 may be or include a backward symbolic engine that expresses the transition system inputs in terms of the procedure inputs.

The translator component 110 can be implemented as a (goal-directed) backward analysis algorithm built on top of an SMT solver. The analysis algorithm can deal with arbitrary operators that are understood by the underlying SMT solver. The analysis algorithm can also employ a proof-rule based non-iterative approach to reason about updates inside loops (therefore facilitating scalability). The proof-rule based technique can capture a common design pattern, wherein numerical variables that are updated inside loops either increase monotonically or decrease monotonically. Such a design pattern can be automatically identified by making an SMT (SAT modulo theory) query. Under such a design pattern, a value of the variable before and after the loop can be related using the number of visits to control locations where the variable is updated inside loops. The number of such visits can be recursively computed as described herein.

The output of the translator component 110 is a reachability bound 112 for the control location π in the procedure P as a function of inputs to the procedure P. As indicated above, the reachability bound 112 may be indicative of the number of times the control location it is visited during execution of the procedure P, and thus may be indicative of a bound pertaining to memory usage of the procedure P, power consumption of a device that executes the procedure P, processor time required to execute the procedure P, bandwidth of a network utilized when executing the procedure P, data perturbation corresponding to the control location π, amongst other bound data.

Now referring to FIG. 2, an example depiction of the transition system generator component 106 is illustrated. As noted above, the transition system generator component 106 can compute a disjunctive transition system T for the control location π that describes how the variables at π get updated at an immediately subsequent visit to π when the procedure P is executed by a computing device. A transition system T that is computable by the transition system generator component 106 can be defined as follows: if {right arrow over (x)} is a tuple of variables that are live at π, then a transition system for π is a relation T({right arrow over (x)},{right arrow over (x)}′) between variables {right arrow over (x)} and their primed counterparts {right arrow over (x)}′ such that if {right arrow over (x)} take values {right arrow over (v₁)} and {right arrow over (v₂)} during any two immediately successive/consecutive visits to π, then T({right arrow over (v₁)},{right arrow over (v₂)}) holds. Additionally, a transition system computed by the transition system generator component 106 can be represented as a disjunction of transitions s, where each transition is a conjunctive relation over variables {right arrow over (x)} and {right arrow over (x)}′.

The transition system generator component 106 includes a splitter component 202 that receives the procedure P and splits the control location π into two locations π_(a) and π_(b). The splitter component 202 can additionally enumerate all paths that start at π_(a) and end at π_(b), and can take disjunctions of the transitions represented by each path. A challenge may arise, however, when enumerating the paths that start at π_(a) and end at π_(b) due to existence of nested loops. Referring briefly to FIG. 3, a representation 300 of operation of the splitter component 202 is shown, where the splitter component 202 splits the control location π into two locations π_(a) and π_(b).

Returning to FIG. 2, the transition system generator component 106 additionally includes a closure determiner component 204 that computes a transitive closure of a transition system of at least one nested loop that lies between locations π_(a) and π_(b). Computation of a transitive closure will now be described in greater detail. T′({right arrow over (x)},{right arrow over (x)}′) is a transitive closure of a transition system T({right arrow over (x)},{right arrow over (x)}′) if Id

T′ and T′•T

T′. Generating a transitive closure of a transition system is similar to computing invariants for a loop representing the transition system. While the below-described technique for computing transitive closure of a transition system is described in connection with computing reachability bounds (or bound analysis in general), it is to be understood that the technique may be applied to other applications, including but not limited to testing safety properties of programs to be executed by computing devices.

An algorithm utilized by the closure determiner component 204 can be based at least in part upon a convexity-like assumption. A theory is said to be convex if and only if for every quantifier-free formula φ in that theory, if φ implies a disjunction of equalities, then it implies one of those equalities, e.g.,: (φ

(V _(i)(x _(i) =y _(i))))

(V _(i)(φ

(x _(i) =y _(i))))

If V_(j=1) ^(m) s′_(k) is a transitive closure of V_(i=1) ^(n) s_(i), then from the definition of transitive closure it follows that for all iε{1, . . . , n} and j ε{1, . . . , m}, the following holds: Id

V _(k=1) ¹ s′ _(k) and s′ _(j) ∘s _(i)

V_(k=1) ^(m) s′ _(k)

After distribution implication over disjunctions in the above equations, the convexity-like assumption can be obtained, which can be defined as follows: T′=V_(j=1) ^(m)s′_(j)({right arrow over (x)},{right arrow over (x)}′) can be a transitive closure for a transition-system T=V_(i=1) ^(n)s_(i)({right arrow over (x)},{right arrow over (x)}′) where each s_(i) and s′_(j) is a conjunctive relation. The transitive closure V_(j)s′_(j) satisfies the convexity-like assumption of there exists an integer δε{1, . . . , m}, a map σ: {1, . . . , m}×{1, . . . , n}

{1, . . . , m} such that for all iε{1, . . . , n} and jε{1, . . . , m}, the following holds: Id

s′ _(δ) and (s′ _(j) ∘s _(i))

s′_(σ(j,i))

The tuple (δ,σ) can be referred to as the convexity-witness of V_(j=1) ^(m)s′_(j). The convexity-like assumption implies that no case-split reasoning is needed to prove inductiveness of transitive closure.

Given the convexity-witness (δ,σ) of any transitive-closure T′ (that satisfies the convexity-like assumption) of a transition system T, the algorithm below can be utilized by the closure determiner component 204 to compute a transitive closure that is at least as precise as T′.

Transitive closure (V_(i=1) ^(n) s_(i)) 1 for j ε {1, ... , m} − {δ}: s′_(j) := false; 2 s′_(δ) := Id; 3 do { 4   for i ε {1, ... , n} and j ε{1, ... , m}: 5   s′_(σ(j,i)) := Join(s′_(σ(j,i)), s′_(j) ∘ s_(i)) 6 } while any change in V_(j=1) ^(m) s′_(j) 7 return V_(j=1) ^(m) s′_(j) The above algorithm performs abstract interpretation over the power-set extension of an underlying abstract domain, where elements are restricted to at most m disjuncts. The algorithm uses the map σ to determine how to merge the n×m different disjuncts (into m disjuncts) that are obtained after propagation of m disjuncts across n transitions.

The above algorithm, when executed by the closure determiner component, may not terminate when computing a Join over domains with infinite height. In an example, a Widen operator can be utilized in plate of the Join operator, for instance, after every threshold number of iterations (e.g., three). Furthermore, the convexity-witness (δ,σ) is unknown up front. Therefore, in an example, all possible (δ,σ) can be enumerated for a specifically chosen m. There may be m^(mn) such possible maps since without loss of generality, it can be assumed that δ is 1. If m and n are relatively small constants such as two, then sixteen possibilities exist. Each selection for σ and δ can result in some transitive closure computation by the above algorithm. The closure determiner component 204 may then select the strongest transitive closure among the various transitive closures thus obtained. In another example, the closure determiner component 204 may heuristically select between incomparable transitive closures.

Additionally or alternatively, the closure determiner component 204 may utilize heuristics to construct m, δ, and σ. For example, the closure determiner component 204 may utilize the following heuristic to construct m, δ, and σ. m can be set at n+1, and δ can be set to m, and the map σ can be selected from a directed acyclic graph (DAG) of dependencies between transitions of the transition system T generated from a bound computation of T (as will be described in detail below). In particular, for any i,j ε{1, . . . , n}, σ(n+1,i):=i,σ(i,i):=i, and σ(i,j):=i except when NI(s_(j), s_(i), r) (where rεRankC (s_(i)) is a ranking function that contributed to the bound computation of T as described below) in which case σ(i,j):=j. Such a choice of the map δ and σ can generate a transitive closure that would allow for computing the bound of T∘TransitiveClosure(T), where TransitiveClosure(T) is an algorithm for computing the transitive closure of a transitive system, such as the algorithm shown above. Such a transitive closure preserves important relationships between program variables that can be employed, for instance, by the bound computation component 108 (FIG. 1).

The system 200 further includes a summarizer component 206 that is configured to replace nested loops between locations π_(a) and π_(b) with the transitive closure of the transition-system of the nested loop (as determined by the closure determiner component 204). Referring briefly to FIG. 4, an example depiction 400 of operation of the summarizer component 206 is illustrated. As indicated above, a summary 402 is a replacement of at least one nested loop.

Pursuant to an example, the following algorithm may be utilized by the transition system generator component 104 to generate a transition system, wherein such algorithm can be a function GenerateTransitionSystem(π):

1 π_(a), π_(b) := Split(π); 2 foreach top-level loop L: 3  π_(L) := location before header of L; 4  T := GenerateTransitionSystem(π_(L)); 5  T_(c) := TransitiveClosure(T); 6  Insert Summary T_(c) before header; Remove back-edges. 7 Initialize F[π_(a)] to the transition system Id. 8 Propagate translations F using Merge/Compose rules. 9 return F[π_(b)] Again, this algorithm can be utilized by the transition system generator component 106 for the control location π. The algorithm is described at a flow-graph level, and an assumption can be made that flowgraphs are reducible but not necessarily structured. It is to be understood, however, that the algorithm can be extended to irreducible flowgraphs.

Line 1 transforms the flowgraph by splitting the input control location π into two locations π_(a) and π_(b). As described above, the splitter component 202 can perform such split, and the result of the split is shown in FIG. 3. Line 2 iterates over each top-level loop L in the transformed flowgraph (any graph can be decomposed into a DAG of maximal strongly-connected components). Line 3 makes use of the fact that every loop in a reducible flowgraph has a unique header node. Line 4 recursively generates the transition system for the loop L in the transformed flowgraph. Line 5 generates the transitive closure for the transition system for the loop L, wherein the closure determiner component 204 can generate such transitive closure. Line 6 replaces the loop L by its summary obtained by generating a transitive closure of the transition-system represented by the transitive closure. As indicated above, the summarizer component 206 can undertake such replacement through actions shown in FIG. 4. The effect of the foreach loop in line 2 is to replace all loops on the paths between π_(a) and π_(b) by (disjunctive) loop-free abstract code fragments. The transition system can be generated by enumerating all paths (which are now finite in number) between π_(a) and π_(b).

Lines 7-9 generate the transition-system for an acyclic flowgraph by simple forward dataflow analysis that associates a (disjunctive) transition system F[π] with each edge/control location π in the transformed flowgraph. For this purpose, the entry location π_(a) can be associated with the transition system consisting of a single transition Id, which is the identity mapping between the variables and their primed versions. Without loss of generality, it can be assumed that all conditional guards have been translated into Assume statements. The merge transfer function returns the disjunctions of the transitions in the two input transition systems. A merger component 208 can perform such merging, and an example graphical illustration 500 of operation of the merger component 208 is shown in FIG. 5. The compose transfer function makes use of the compose operator ∘ that returns the composition of two transitions. The composer component 210 can perform such composition, and an example graphical illustration 600 of operation of the composer component 210 is shown in FIG. 6.

Composition of transition systems output by the composer component 210 can be defined as follows: the binary composition of two transition systems T({right arrow over (x)},{right arrow over (x)}′)=V_(i)s_(i) and T′({right arrow over (x)},{right arrow over (x)}′)=V_(j)s′_(j), denoted by T∘T′, is V_(i,j)s_(i)∘s′_(j), where s_(i)∘s′_(j) denotes the following transition: s_(i)({right arrow over (x)},{right arrow over (x)}′)∘s′_(j)({right arrow over (x)},{right arrow over (x)}′)

∃{right arrow over (x)}″(s_(i)[{right arrow over (x)}″/{right arrow over (x)}′]

s′_(j)[{right arrow over (x)}″/{right arrow over (x)}]), where s_(i)[{right arrow over (x)}″/{right arrow over (x)}] denotes the substitution of {right arrow over (x)}′ by {right arrow over (x)}″ in s_(i).

The transition system generator component 106 may also utilize a Translate function that converts a statement into a transition-system. Such a function may act as follows: it can be assumed that the only assignment statement is of the form x:=e since memory can be modeled using Select and Update expressions. The other kinds of statements can be either an Assume statement (obtained from the conditional guards) or Summary statement (obtained from summarization of nested loops):

Translate(x:=e)=(x′=e)

(

_(y≠x)y′=y)

Translate(Assume(guard))=Id

guard

Translate(Summary(T))=T

Now referring to FIG. 7, a detailed depiction of the bound computation component 108 is illustrated. As indicated above, the bound computation component 108 can compute a bound for the transition system T. If a transition-system consists of a single transition s, then the bound computation component 108 can compute a bound for the transition system from a ranking function r of the transition s.

Theorem 1: If there exists a ranking function r for a transition s, then the number of iterations of s is bounded above by Max(0,r).

Proof: If the transition s is ever taken, then r denotes an upper bound on the number of iterations of s (since, by definition of a ranking function, transition s implies that r is lower bounded by zero and decreases by at least one in each iteration). The other case is when s is never executed (i.e., the number of iterations of s is zero). Combining such two cases provides the result shown in Theorem 1.

Any suitable ranking function can be employed, and any suitable manner for computing a ranking function can be utilized. Example approaches for computing ranking functions are described in greater detail below. Computing a bound for a transition-system that includes multiple transitions is somewhat more complex than computing a bound for a transition-system that includes a single transition. For instance, the bound computation component 108 cannot add ranking functions of individual transitions to compute the bound for the transition-system, since the interleaving of such transitions with each other can invalidate the decreasing measure of the ranking function. Another approach can be to define the notion of lexicographic ranking functions or disjunctively well-founded ranking functions for transition-systems consisting of multiple transitions.

The bound computation component 108 can include a rank finder component 702, which be employed to compute one or more ranking functions. Example techniques for computing ranking functions are described herein. It is to be understood, however, that any suitable ranking function may be employed by the bound computation component 108 in connection with computing a bound pertaining to a transition-system. For example, the rank finder component 702 can generate a ranking function using arithmetic iteration patterns, list iterations patterns, etc. Additionally, ranking functions computed by the rank finder component 702 may be utilized outside of the context of computing reachability bounds.

As used herein, a ranking function for a transition can be defined as follows: a real-valued function r({right arrow over (x)}) is a ranking function for a transition s({right arrow over (x)},{right arrow over (x)}′) if it is lower bounded by zero and if it decreases by at least one in each execution of the transition: e.g.: s

(r>0) s

(r[{right arrow over (x)}′/{right arrow over (x)}]≦r−1) This can be denoted by Rank (s,r).

A ranking function r₁({right arrow over (x)}) may be deemed more precise than a ranking function r₂({right arrow over (x)}) if r₁({right arrow over (x)})≦r₂({right arrow over (x)}) (because in such a case r₁ provides a more precise bound for the transition than r₂.

The rank finder component 702 may utilize a RankC function that takes as input a transition s({right arrow over (x)}, {right arrow over (x)}′) and outputs a set of ranking functions r({right arrow over (x)}) for that transition. Additionally, the rank finder component 702 may use one or more pattern-matching-based techniques that rely on making some queries that can be discharged using an SMT solver. Other techniques, such as constraint-based techniques or iterative fixed-point computation based-techniques can also be utilized for generating ranking functions.

Example patterns that can be utilized by the rank finder component 702 to output ranking functions are described herein. A first set of example patterns include arithmetic iteration patterns. One standard manner to iterate over loops is to use an arithmetic counter. Ranking functions for such an iteration pattern can be computed using the following pattern: If s

(e>0

e[{right arrow over (x)}′/{right arrow over (x)}]<e), then eεRankC(s).

The candidates for expression e while applying the above pattern are restricted to expressions that only involve variables from {right arrow over (x)} and those that occur syntactically as an operand of conditionals when normalized to the form (e>0), after rewriting a conditional of the form (e₁>e₂) to (e₁−e₂>0). The following are some example transitions whose ranking functions can be computed using an application of this pattern: RankC(i′=i+1

i<n

i<m

n′=n

m′≦m)={n−i,m−i}; RankC(n>0

n′≦n

A[n]≠A[n′])={n} The second example transition above is an illustration of how simple pattern matching can be employed by the rank finder component 702 to guess a ranking function, and an SMT solver (that can reason about combination of theory of linear arithmetic and theory of arrays) can be used to perform the relatively complicated reasoning of verifying the ranking function over loop-free code fragment.

Another arithmetic pattern is the use of a multiplicative counter whose value doubles or halves in each iteration (as in case of binary search). A more precise ranking function for such a transition can be computed using the pattern below: If s

(e≧1

e[{right arrow over (x)}′/{right arrow over (x)}]≦e/2), then log eεRankC(s) The candidates for expression e while applying the above pattern are restricted to those expressions that only involve variables from {right arrow over (x)} and those that occur syntactically as an operand of conditionals when normalized to the form (e>1), after rewriting a conditional of the form (e₁>e₂) that occurs in s to

$\left( {\frac{e_{1}}{e_{2}} > 1} \right),$ provided e₂ is known to be positive. The following are additional transitions whose ranking functions can be computed using an application of this pattern:

${{Rank}\;{C\left( {i^{\prime} \leq {\frac{i}{2}\bigwedge i} > 1} \right)}} = \left\{ {\log\mspace{11mu} i} \right\}$ Rack C(i^(′) = 2 × i⋀i > 0⋀n > i⋀n^(′) = n) = {log (n/i)} These two patterns can be utilized by the rank finder component 702 to compute ranking functions for loops that iterate using arithmetic counters. If pattern matching is not sufficient for a particular case, then other methods can be used, such as counter instrumentation and invariant generation techniques, some of which are described in “A Numerical Abstract Domain Based on Expression Abstraction and Max Operator with Application in Timing Analysis”, by Gulavani and Gulwani, in CAV, pages 370-384, published in 2008, the entirety of which is incorporated herein by reference.

In another example, the rank finder component 702 may use Boolean iteration patterns to compute ranking functions. Often loops contain a path/transition that is meant to execute a single time. The purpose of such a transition is to switch between different phases of a loop or to perform the cleanup action immediately prior to loop termination. Such an iteration pattern can be captured by the following rule/lemma, where the operator Bool2Int(e) maps Boolean values true and false to 1 and 0, respectively. If s

(e

not(e[{right arrow over (x)}′/{right arrow over (x)}])), then Bool2Int(e) εRankC(s)

The candidates for Boolean expression e while applying the above pattern may be restricted to expressions that only involve variables from {right arrow over (x)} and those that occur syntactically in the transition s. Below are some example transitions whose ranking functions can be computed by the rank finder component 702 using an application of this pattern. RankC(flag′=false

flag)={Bool2Int(flag)} RankC(x′=100

x<100)={Bool2Int(x<100)}

In yet another example, the rank finder component 702 may use bit-vector iteration patterns in connection with computing ranking functions. An example manner of iterating over a bit-vector is to alter the position of the least significant one bit (or most significant one bit). Such an iteration pattern can be captured by the following rule/lemma, where the function LSB(x) denotes the position of the least significant 1-bit, counting from 1, and starting from the most-significant bit position. LSB(x) can be defined to be zero if there is no 1-bit in x. Additionally, LSB(x) can be bounded above by the total number of bits in bit-vector x. If s

(LSB(x′)<LSB(x)

x≠0), then LSB(x)εRankC(s)

The candidates for variable x while applying such pattern can be bit-vector variables that occur in the transition s. The query in the above pattern can be discharged using an SMT solver that provides support for bit-vector reasoning, and, in particular, the LSB operator (if the SMT solver does not provide first-class support for the LSB operator, then the LSB operator can be encoded using bit-level manipulation). The following two example transitions can have a bound computed using the above rule: RankC(x′=x<<1

x≠0)={LSB(x)} RankC(x′=x&(x−1)

x≠0)={LSB(x)}

In still yet another example, the rank finder component 702 can compute a ranking function through utilization of data structure iteration patterns. Iteration over data structures or collections is common, and one example manner to iterate over a data structure is to follow field dereferences until some designated object is reached. Such an iteration pattern can be captured by the following rule/lemma, where the function Dist (x,z,f) denotes the number of field dereferences along field f needed to reach z from x: If s

(x≠z

(Dist(x′,z,f)<Dist(x,z,f))), then Dist(x,z,f)εRankC(s)

The candidates for variables x, z, and field f while applying the above pattern are variables {right arrow over (x)} and field names that occur in s. The query in the above pattern can be discharged using an SMT solver that implements a decision procedure for the theory of reachability and can reason about its cardinalities. It can be noted that Dist (x,z,f) denotes the cardinality of the set of nodes that are reachable from x before reaching z along field f. Below are example transitions whose ranking functions can be computed using an application of this pattern: RankC(x≠Null

x′=x.next)={Dist(x,Null,next)} RankC(Mem′=Update(Mem,x.next,x.next.next)

x≠Null

x.next≠Null)={Dist(x,Null,next)}

As indicated above, the bound computation component 108 can compute a bound for a transition system based at least in part upon a ranking function of the transition system computed by the rank finder component 702. In an example, the bound computation component 108 can utilize a max composition of ranking functions approach to compute a bound for the transition system T. For instance, the bound for a transition-system that comprises of two transitions s₁ and s₂ can be obtained by applying the Max operator to the ranking functions for the individual transitions when the transitions are either disjoint or they decrease the ranking function of the other. More formally, there is a cooperative interference between transitions s₁ and s₂ through their respective ranking functions r₁ and r₂ if either of the following conditions hold: (1) s₁∘s₂=false (non-enabling condition); and (2) s₁

r₂[{right arrow over (x)}′/{right arrow over (x)}]≦Max(r₁,r₂)−1(rank-decrease condition). This cooperative interference can be denoted by CI(s₁, r₁, s₂, r₂).

Theorem 2 Given r₁ εRankC(s₁) and r₂ εRankC (s₂), if CI(s₁, r₁, s₂, r₂)

CI(s₂, r₂, s₁, r₁), then Bound (s₁ V s₂)=Max(0, r₁, r₂)

Proof: Four cases can be considered: (1) If both transitions s₁ and s₂ satisfy the non-enabling condition, then either only transition s₁ can execute or only transition s₂ can execute; (2) If both transitions satisfy the rank-decrease condition, then it can be shown that Max(r₁, r₂) is a ranking function for both the transitions s₁ and s₂; (3) if transition s₁ satisfies the non-enabling condition while transition s₂ satisfies the rank-decrease condition, then the only possibility is that a sequence of transitions s₂ is followed by a sequence of transitions s₁. The result now follows from the fact that Max(r₁,r₂) is a ranking function for s₂, while r₁ is a ranking function for s₁; (4) the last case is similar to (3). Therefore, the bounds for transitions can be composed using a Max operator if the transitions satisfy the cooperative interference conditions.

In another example, the bound computation component 108 can compute a bound for a transition system that comprises two transitions s₁ V s₂ by adding together the ranking functions for the two transitions under cases when a transition does not interfere with the ranking functions of the other transition. Non-interference of a transition with respect to a ranking function of another transition can be defined as follows: a transition s₁ does not interfere with the ranking function of another transition s₂ if one of the following conditions holds: (1) s₁∘s₂=false (non-enabling condition); or (2) s₁

(r₂[{right arrow over (x)}′/{right arrow over (x)}]≦r₂)(rank-preserving condition). Such non-interference can be denoted by NI(s₁, s₂, r₂). Given the above, the following theorem holds, where the notation Iter(s) denotes the total number of iterations of transition s inside its transition system:

Theorem 3: Given r₁ εRankC(s₁), r₂ εRankC (s₂), if NI(s₁, s₂, r₂)

NI(s₂, s₁, r₁), then Bound(s ₁ V s ₂)=Iter(s ₁)+Iter(s ₂), where Iter(s ₁)=Max(0,r ₁) Iter(s ₂)=Max(0,r ₂)

Proof: The non-interference condition NI(s₂, s₁, r₁) ensure that the value of the ranking function r₁ for transition s₁ is not increased by any interleaving of transition s₂. Thus, a total number of iterations of the transition s₁ is given by Max(0,r₁). Similarly, the total number of iterations of the transition s₂ is given by Max(0,r₂). Therefore, bounds for transitions can be composed using the Addition operator if the transitions satisfy the non-interference conditions.

In another example, the bound computation component 108 can compute bounds by way of multiplicative composition of ranking functions computed by the rank finder component 702. For instance, if mutual cooperative-interference or mutual non-interference of two transitions cannot be established, then the bound computation component 108 can compute a bound so long as at least one of the transitions satisfies the non-interference property described above. The bound in such a case can be computed by multiplying together the ranking functions for the two transitions. Such multiplication can be made precise as shown in the following theorem. This is a relatively common case for bounding iterations of an inner loop when its iterators are reinitialized inside the outer loop leading to a multiplicative bound.

Theorem 4: Given r₁εRankC (s₁) and r₂ εRankC(s₂), if NI(s₂, s₁, r₁), then Bound(s ₁ V s ₂)=Iter(s ₁)+Iter(s ₂), where Iter(s ₁)=Max(0,r ₁); Iter(s ₂)=Max(0,r ₂)+Max(0,u ₂)×factor; where factor=Max(0, r₁) and u₂({right arrow over (x)}) denotes an upper bound on expression r₂({right arrow over (x)}′) in terms of {right arrow over (x)} as implied by TC (s₁). For the special case where (r₁>0)

s₂ is unsatisfiable, the factor can be set to one.

Proof: From the non-interference condition NI(s₂, s₁,r₁), it can be concluded that Iter(s₁)≦Max(0, r₁). However, this does not hold for s₂. Instead it can be observed that the maximum number of iterations of s₂ in between any two interleavings of s₁ is bounded above by Max(0,u₂) (since the starting value of the ranking function r₂ is reset to u₂ by any execution of s₁). The number of iterations of s₂ before any interleaving of s₁ is still bounded by Max (0,r₂). Thus, the total number of iterations of s₂ is bounded by Max(0,r₂)+Max (0,u₂)×Max(0,r₁). The special case follows from the observation that even though s₁ interferes with the ranking function r₂ of s₂, it can interfere at most once since s₁ is enabled only after completion of all iterations of s₁. In other words, the worst-case possibility is a sequence of transitions s₂ followed by a sequence of transitions s₁ followed by a sequence of transitions s₂. Therefore, the bounds for transitions can be composed using a Multiplication operator if one of the transitions satisfies the non-interference condition.

An example algorithm (referred to herein as the ComputeBound algorithm) that can be executed by the bound computation component 108 in connection with computing a bound for a transition system is shown below.

ComputeBound(V_(i=1) ^(n) s_(i)) 1 for i ε {1, ... , n}: Iter[s_(i)] :=⊥; 2 do { 3  for i ε {1, ... , n} and r ε RankC(s_(i)): 4   J := {j| 

NI(s_(j), s_(i), r)}; 5   if (Iter[s_(i)] =⊥)

 (∀j ε J: Iter[s_(j)] ≠⊥) 6    factor := 0; 7    foreach j ε J: factor := factor + Max(0, r); 8    Let u({right arrow over (x)}) be an upper bound on r [{right arrow over (x)}′/{right arrow over (x)}] as implied by    TC(V_(j≠i) s_(j)) 9    Iter[s_(i)] := Max(0, r) + Max(0, u) × factor; 10 } while any change in Iter array; 11 if (∀j ε {1, ... , n}: Iter[s_(j)] ≠⊥), return Σ_(j) Iter [s_(j)]; 12 else return “Potentially Unbounded”

Thus, the bound computation component 108 can combine the composition rules discussed above for transition systems with more than two transitions. For instance, it can be ascertained that an optimal manner of applying the rules pertaining to Additive-Composition and Multiplicative-Composition (theorems 3 and 4, respectively) is to compute the total number of iterations for each transition individually and thereafter sum the results. The ComputeBound algorithm implements such a strategy based on an extension of Theorem 3 and Theorem 4 to the case when a transition system comprises more than two transitions. The algorithm iteratively computes an array her such that Iter[s_(i)] denotes a bound on a total number of iterations taken by the transition s_(i) during any execution of the transition system S_(i)

. . .

s_(n). The array J at line 4 comprises indices of all transitions that interfere with the ranking function r of the transition s_(i). If a bound on the total iterations of all such transitions is known (test on Line 5 of ComputeBound), then the iterations of 5, is computed using a generalization of Theorem 3 and Theorem 4 (Line 9 of ComputeBound). The bound computation component 108 can compute bound on the entire transition system by summing up bounds on the total number of iterations of the individual transitions (Line 11 of ComputeBound). While ComputeBound is shown to output a single bound, it is to be understood that the bound computation component 108 can utilize an algorithm that computes multiple bounds by relaxing the condition Iter[s_(i)]=⊥ in Line 5 of ComputeBound by associating a set of bounds with Iter[s_(i)](as opposed to a single bound).

Additionally, the ComputeBound algorithm can be extended, such that the extension takes advantage of the proof rule in Theorem 2. For example, RankC(s) can be extended for any transition s with Max(r,r′), where r εRankC(s) and r′εRankC(s′) for some other transition s′, provided Rank(s, Max(r,r′)), before running the ComputeBound algorithm. This allows for an application of Theorem 3 to obtain an additive bound that is a constant factor of two away from what would have been obtainable from application of Theorem 2. Thus, the bounds for transitions can be composed using a combination of Max, Addition, and Multiplication operators.

With reference now to FIGS. 8-9, various example methodologies are illustrated and described. While the methodologies are described as being a series of acts that are performed in a sequence, it is to be understood that the methodologies are not limited by the order of the sequence. For instance, some acts may occur in a different order than what is described herein. In addition, an act may occur concurrently with another act. Furthermore, in some instances, not all acts may be required to implement a methodology described herein.

Moreover, the acts described herein may be computer-executable instructions that can be implemented by one or more processors and/or stored on a computer-readable medium or media. The computer-executable instructions may include a routine, a sub-routine, programs, a thread of execution, and/or the like. Still further, results of acts of the methodologies may be stored in a computer-readable medium, displayed on a display device, and/or the like.

Referring now to FIG. 8, a methodology 800 that facilitates computing a symbolic bound with respect to a control location in a procedure that is executable by a processor in a computing device is illustrated. The methodology 800 begins at 802, and at 804 a procedure is received. For instance, the procedure can be retained in a computer-readable medium, such as a hard drive, memory, or other suitable medium, and such medium can be accessed to retrieve the procedure. For example, the procedure may include one or more nested loops.

At 806, a transition system is generated with respect to a control location in the procedure. The control location can be automatically located or specified by an individual. Moreover, the transition system can include one or more transitions.

At 808, a symbolic bound is computed with respect to the transition system in terms of inputs to the transition system. For example, ranking functions for individual transitions can be computed (using, for example, pattern matching techniques) and then composed together in connection with computing the symbolic bound. At 810, the symbolic bound is translated such that the symbolic bound is in terms of inputs to the procedure. The methodology 800 completes at 812.

With reference now to FIG. 9, an example methodology 900 that facilitates computing a symbolic bound with respect to a control location in a procedure is illustrated. The methodology 900 starts at 902, and at 904 a transition system pertaining to the control location in the procedure is received. At 906, a bound on each transition in the transition system is determined. At 908, the bounds on each transition are composed together using Max, Addition, and Multiplication operators using theorems 2-4, such as done in the ComputeBound algorithm. The methodology 900 completes at 910.

Now referring to FIG. 10, a high-level illustration of an example computing device 1000 that can be used in accordance with the systems and methodologies disclosed herein is illustrated. For instance, the computing device 1000 may be used in a system that supports computing a symbolic bound with respect to a procedure. In another example, at least a portion of the computing device 1000 may be used in a system that supports computing a transition system with respect to a control location in a procedure. The computing device 1000 includes at least one processor 1002 that executes instructions that are stored in a memory 1004. The instructions may be, for instance, instructions for implementing functionality described as being carried out by one or more components discussed above or instructions for implementing one or more of the methods described above. The processor 1002 may access the memory 1004 by way of a system bus 1006. In addition to storing executable instructions, the memory 1004 may also store a transition system, one or more bound computation rules, etc.

The computing device 1000 additionally includes a data store 1008 that is accessible by the processor 1002 by way of the system bus 1006. The data store 1008 may include executable instructions, procedures, etc. The computing device 1000 also includes an input interface 1010 that allows external devices to communicate with the computing device 1000. For instance, the input interface 1010 may be used to receive instructions from an external computer device, from an individual, etc. The computing device 1000 also includes an output interface 1012 that interfaces the computing device 1000 with one or more external devices. For example, the computing device 1000 may display text, images, etc. by way of the output interface 1012.

Additionally, while illustrated as a single system, it is to be understood that the computing device 1000 may be a distributed system. Thus, for instance, several devices may be in communication by way of a network connection and may collectively perform tasks described as being performed by the computing device 1000.

As used herein, the terms “component” and “system” are intended to encompass hardware, software, or a combination of hardware and software. Thus, for example, a system or component may be a process, a process executing on a processor, or a processor. Additionally, a component or system may be localized on a single device or distributed across several devices.

It is noted that several examples have been provided for purposes of explanation. These examples are not to be construed as limiting the hereto-appended claims. Additionally, it may be recognized that the examples provided herein may be permutated while still falling under the scope of the claims. 

What is claimed is:
 1. A system that facilitates computing a symbolic bound on the number of visits to a control location inside a procedure, the system comprising: a processor; and a memory that comprises a plurality of components that are executed by the processor, the plurality of components comprising: a transition system generator component that receives the procedure and computes a disjunctive transition system for the control location in the procedure, the disjunctive transition system, for each visit to the control location, indicating how variables in the procedure are updated when the control location is next visited; a bound computation component that computes a bound for the transition system, wherein the bound is expressed in terms of inputs to the transition system; and a translator component that translates the bound computed by the bound computation component such that the bound is expressed in terms of inputs to the procedure.
 2. The system of claim 1, wherein the bound is computed with respect to a physical resource of a computing system.
 3. The system of claim 2, wherein the physical resource is one of memory space allocated to the procedure when executing the procedure on the computing system, processing time utilized by the computing system when executing the procedure, power utilized by the computing system when executing the procedure, or bandwidth consumed when executing the procedure.
 4. The system of claim 1, wherein the bound is computed with respect to at least one of perturbation of data corresponding to the procedure or secret leak corresponding to the procedure.
 5. The system of claim 1, wherein the transition system generator component splits the control location into two locations π_(a) and π_(b), wherein π_(a) is representative of an execution of the control location and π_(b) is representative of an immediately next visit to the control location, wherein the transition system generator component enumerates paths that start at π_(a) and end at π_(b), and wherein the transition system generator component computes disjunctions of the transitions represented by each path.
 6. The system of claim 5, wherein the transition system generator component recursively computes a transition system for each loop that lies between π_(a) and π_(b) in the procedure followed by computing a transitive closure for each loop that lies between π_(a) and π_(b) in the procedure.
 7. The system of claim 6, wherein the transitive closure is generated using an abstract interpretation based technique relying on a convexity-like assumption to compute precise disjunctive invariants.
 8. The system of claim 1, wherein the bound computation component computes the bound for the transition system based at least in part upon computing ranking functions for individual transitions.
 9. The system of claim 8, wherein the bound computation component generates the ranking function based at least in part upon at least one pattern matching technique.
 10. The system of claim 9, wherein the bound computation component generates the ranking function using one or more of bit-vector iteration patterns, arithmetic iterations patterns, list iteration patterns, or Boolean iteration patterns.
 11. The system of claim 8, wherein the bound for the transition system is composed using at least one of the following: a Max operator if the transitions satisfy cooperative interference conditions; an Addition operator if the transitions satisfy non-interference conditions; or a Multiplication operator if one or more of the transitions satisfies a non-interference condition.
 12. The system of claim 8, wherein the bound for the transition system is composed using a combination of Max, Addition, and Multiplication operators.
 13. The system of claim 1, wherein the translator component uses one or more of the following to relate inputs to the disjunctive transition system to inputs of the procedure: invariants; or backward symbolic execution, wherein the backward symbolic execution uses proof-rule based non-iterative techniques to trace back across loops.
 14. A method for computing a reachability bound on a control location inside a procedure that is executable by a processor in a computing device, wherein the method comprises: accessing a computer-readable medium to retrieve the procedure; generating a transition system with respect to the control location in the procedure, the transition system indicating, for each visit to the control location when the procedure is executed, how a variable is updated in an immediately subsequent visit to the control location when the procedure is executed; computing a symbolic bound with respect to the control location, wherein the symbolic bound is expressed in terms of inputs to the transition system; and translating the symbolic bound into the reachability bound, wherein the reachability bound is expressed in terms of inputs to the procedure.
 15. The method of claim 14, wherein the reachability bound is computed with respect to a physical resource of the computing device.
 16. The method of claim 15, wherein the physical resource of the computing device is one of memory space allocated to the procedure when executing the procedure on the computing device, processing time utilized by the computing device when executing the procedure, power utilized by the computing device when executing the procedure, or bandwidth consumed when executing the procedure.
 17. The method of claim 14, wherein computing the symbolic bound with respect to the control location comprises computing a ranking function for each transition in the transition system, and then composing the ranking functions using max, addition, or multiplication operators.
 18. The method of claim 17, wherein pattern-matching techniques are utilized to compute the ranking function.
 19. The method of claim 14, wherein the reachability bound is indicative of a number of times that the control location is visited during execution of the procedure.
 20. A computer-readable memory comprising instructions that, when executed by a processor, cause the processor perform acts comprising: accessing a data repository to retrieve a procedure; generating a transition system with respect to a control location in the procedure, the transition system indicating, for each visit to the control location when the procedure is executed, how a variable is updated in an immediately subsequent visit to the control location when the procedure is executed; computing a bound with respect to the control location, wherein the bound is expressed in terms of inputs to the transition system, wherein the bound is computed based at least in part upon a ranking function of each transition in the transition system, and wherein the ranking function is computed based at least in part upon pattern-matching techniques; and translating the bound into a reachability bound, wherein the reachability bound is expressed in terms of inputs to the procedure, and wherein the reachability bound is indicative of a number of visits to the control location when the procedure is executed. 